// ==UserScript==
// @name Optimize 163.com in Opera
// @author nanzhi at 12sui.cn
// ==/UserScript==

/**
 * 163二级频道
 * @url http://*.163.com
 * @description 163二级频道的频道内导航条优化，将在新窗口打开更改为本窗口打开，适用频道：科技、娱乐、新闻，可能其它类似频道也适用
 */

if(location.hostname.indexOf('.163.com') != -1 && location.hostname.indexOf('www.163.com') == -1) {
	document.addEventListener(
		'DOMContentLoaded',
		function() {
			var el = document.getElementsByClassName('nav');		
			for(var i=0;i<el.length;i++) {
				if(el[i].parentNode.className == 'nav_channel') {
					el[i].addEventListener(
						'click',
						function(e) {
							var target = e.target;
							if(target.tagName.toLowerCase() == 'a') {
								e.preventDefault();
								window.location.href = target.href;
							}
						},false
					);
					break;
				}
			}
		},false
	);
}
